/**
 * 解法1  carl
 * @param {*} nums 
 * @returns 
 */
var removeDuplicates = function(nums) {
    const n =nums.length
    let left =0
    for(var right=0;right<n;right++){
        if(nums[right]!==nums[right+1]){
            nums[++left]=nums[right+1]
        }
    }
    return left+1
};


/**
 * 解法二
 * 自创
 * @param {*} nums 
 * @returns 
 */

var removeDuplicates = function(nums) {
    const n =nums.length
    let left =0
    for(var right=1;right<n;right++){
        if(nums[right]!==nums[left]){
            nums[++left]=nums[right]
        }
    }
    return left+1
};